package com.darwin.darwinGpuEngine.core
{
	import com.darwin.darwinGpuEngine.core.materials.SpriteSheet;
	
	import flash.display.BitmapData;
	import flash.geom.Rectangle;
	
	/**
	 * GMovieNode
	 * @author Roland
	 */
	public class GMovieNode extends GNode
	{
		//帧频  
		private var _frameRate:int = 24;
		//两帧间隔时间 
		private var _frameInterval:int;
		
		private var _sheet:SpriteSheet;
		public function GMovieNode(bitmapData:BitmapData = null,frameRect:Rectangle = null,frameList:Array = null)
		{
			super(bitmapData);
			if(bitmapData != null && frameRect != null)
			{
				_sheet = new SpriteSheet(bitmapData.width,bitmapData.height,frameRect.width,frameRect.height,_frameRate,false);
				setSpriteSheet(_sheet);
				var frames:Array = [];
				for (var i:int = 0; i < _sheet.numSheets; i++) 
				{
					frames.push(i);
				}
				
				_sheet.addAnimation("default",frames,true);
				_sheet.playAnimation("default");
			}
		}
		
		/**
		 * 帧速率 
		 */
		public function get frameRate():int
		{
			return _frameRate;
		}
		
		/**
		 * @private
		 */
		public function set frameRate(value:int):void
		{
			_frameRate = value;
			_frameInterval = 1000/frameRate;
			if(_sheet)
			{
				_sheet.frameRate = _frameRate;
			}
		}
	}
}